<?php
// you should change the parms with your values
define(DB_HOST,'localhost');
define(DB_NAME,'catfly');
define(DB_USER,'root');
define(DB_PASSWORD,'shi1983');


class DB {	
	

	function init () {
		
		$this -> mysql['conn_error'] ="<b>Mysql got an error while trying to connect to the server.</b\n>";
		$this -> mysql['db_error'] ="<b><b>Mysql got an error while trying to use to the server.</b></b>";
		$this -> mysql['gen_error'] = "<b><b>MySQL Error: <b>Due to a database error this page cannot be displayed</b>";
	}	
	
	/**
	 * this functioni is used to setup the connection to the DB server and use the table
	 *
	 */
	function conn_mysql(){
		$this -> init();
		$mysql_conn = mysql_connect(DB_HOST,DB_USER, DB_PASSWORD);
		$mysql_db = mysql_select_db(DB_NAME,$mysql_conn);
		if (!$mysql_conn) {
			echo  $this -> mysql['conn_error'];
		}elseif(!$mysql_db) {
			echo $this -> mysql['db_error'];			
		}
	}
	
	function run_sql_query($sql) {
		$query_result = mysql_query($sql);
		if (!$query_result) {
			echo $this -> mysql['gen_error'];		
			return false;	
		} else {			
			return $query_result;
		}
		
	}
//	
		function return_sql_array($sql_code)
	{
		$sql_result = @mysql_query($sql_code);
		
		if ($sql_result){			
			$sql_array = @mysql_fetch_array($sql_result);
			return ($sql_array);
		}
	}
	
}

?>